-
Notifications
You must be signed in to change notification settings - Fork 8
feat: CI improvements and web UI implementation #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MBanucu
wants to merge
344
commits into
shekohex:main
Choose a base branch
from
MBanucu:fix-ci-shekohex
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add tests that spawn test servers and capture log output - Verify local time display in pretty-printed logs with SYS: prefix - Test LOG_LEVEL environment variable handling - Test CI environment forcing debug level - Validate log structure and formatting across different configurations - Use yargs for command line argument parsing in test server
Remove duplicate test cases and update assertions to match the actual pretty-printed log output format from the web server instead of expecting JSON fields. Also, add ISO timestamp configuration to the web logger for consistency.
…2e tests - Use relative paths for session API calls to respect Playwright baseURL - Replace invalid DELETE /api/sessions with POST /api/sessions/clear - Add WebSocket connection wait before checking empty session state - Enhance empty state test with proper session creation and autoselect disable
- Clear existing sessions before each WS counter test for clean state isolation - Increase test timeout to accommodate session startup delays - Add session output verification and enhanced logging for debugging - Modify session commands to produce continuous output instead of one-time echoes - Ensure reliable WebSocket message counting across test scenarios
- Add worker-scoped fixture for spawning dedicated server per worker - Calculate unique ports (8877 + workerIndex) for each worker - Remove global webServer config in favor of dynamic server management - Update test files to use extended test object with server fixtures - Enable parallel execution with true isolation between workers - Update worker count: 3 locally, 8 on CI for optimal performance This provides clean parallel test execution with no cross-worker state pollution.
…st fixtures Remove hardcoded environment variables and let the test server inherit NODE_ENV and LOG_LEVEL from the parent process environment.
…g log This warning was too verbose during test execution and is now logged at debug level to reduce noise while maintaining diagnostic information.
- Fix server to serve built HTML and assets in test mode instead of source files - Add TypeScript file serving for browsers in test environment - Improve test isolation with session clearing and proper cleanup - Fix API URL construction in tests - Increase timeouts for reliable parallel execution - Enhance server startup robustness and PTY process cleanup This resolves issues where tests passed serially but failed in parallel due to UI loading failures, resource conflicts, and timing issues.
Add a new slash command `/server-url` that dynamically registers at plugin initialization using `client.config.update()`. The command uses the new `pty_server_url` tool to retrieve and display the running web server URL, providing users with easy access to the PTY web interface for managing sessions.
- Move web server start and command registration from plugin init to config function - Add build:plugin script for easier plugin bundling - Improve HTML path resolution using import.meta.dir
.opencode/ contains local testing setup and built plugins that should not be committed to version control. This ensures the local development environment remains developer-specific.
- Add install:plugin:dev script to build plugin and copy to .opencode/plugins/ - Add install:web:dev script for web UI development build - Add install:all:dev script to run both installation steps These scripts automate the workflow for setting up the local development environment with the latest built plugin and web UI.
- Add @xterm/xterm and @xterm/addon-fit dependencies for proper terminal emulation - Create TerminalRenderer component using xterm.js for ANSI sequence rendering - Update App.tsx to use TerminalRenderer instead of plain div for PTY output - Handle live streaming by appending new output lines to the terminal - Support terminal resizing with fit addon This provides realistic terminal rendering with colors, cursor movements, and proper ANSI/VT100 sequence support for PTY output.
Updated lockfile to include @xterm/xterm and @xterm/addon-fit packages.
- Remove separate input field and send button UI - Add input handling to TerminalRenderer with line buffering - Capture user keystrokes in xterm.js and send to PTY backend - Implement backspace editing and Ctrl+C interrupt handling - Integrate input callbacks with existing session management - Disable input when PTY session is not running Users can now type directly in the terminal for authentic PTY interaction.
…led commands - Remove manual local echo and line buffering logic - Let xterm.js handle native editing (backspace, arrows, cursor movement) - Send raw keystroke chunks to backend instead of trimmed lines - Update output writing to join without extra newlines - Properly dispose event listeners to prevent memory leaks - Focus terminal automatically for immediate typing - Increase scrollback to 5000 lines for better history This fixes issues with duplicated/mangled input like 'echo "Hello World"echo "Hello World"' and ensures proper terminal behavior for editing, history, and control sequences.
- Add console.log in onDataHandler to track sent keystrokes - Temporarily add local echo for space character to isolate backend echo issues - This helps determine if spacebar events are received and if backend responds Remove after confirming the issue and fixing backend echo.
- Add comprehensive Playwright test for input capture functionality - Test captures printable characters (letters) sent to backend - Test Enter key handling for command submission - Test backspace sequences - Test Ctrl+C interrupt handling - Test input blocking when session is inactive - Use fixtures.ts for isolated test server management - Note: space character has known capture issue (test excludes it) The test verifies that user input is properly captured by xterm.js and sent to the PTY backend via API requests.
- Add logger.debug in TerminalRenderer onData handler - Add logger.debug in App handleSendInput for input data - Set LOG_LEVEL=debug in fixtures for test debugging - This helps trace input capture flow from xterm to backend
- Add Sidebar component for visual session management with status indicators - Implement TerminalRenderer with xterm.js integration for interactive terminal - Add comprehensive input handling for keyboard input (letters, spaces, Enter, Ctrl+C) - Fix input validation to properly handle whitespace characters - Enhance logging in PTY manager for better debugging - Add e2e tests for input capture including spacebar and Enter key verification - Update AGENTS.md with web UI features and testing documentation - Refactor App component for better separation of concerns The web UI provides a modern interface for managing PTY sessions with real-time output streaming, session selection, and direct terminal interaction.
Add complete web-based terminal interface for PTY session management using xterm.js for authentic terminal rendering and real-time interaction. Key features implemented: - Interactive terminal with xterm.js for accurate terminal emulation - Real-time input capture and command execution - Session management (create, select, kill sessions) - Live output streaming with historical data loading - Proper input handling including Ctrl+C interrupts - Responsive UI with session sidebar and status indicators Technical improvements: - Replaced HTML div rendering with xterm.js canvas-based terminal - Added session description support for better identification - Implemented proper session lifecycle management - Added test output div for E2E test compatibility - Enhanced error handling and logging Tests updated to work with xterm.js: - Fixed all input capture tests for keyboard input, commands, and interrupts - Added session isolation to prevent parallel test interference - Updated selectors to work with xterm.js DOM structure - Maintained test coverage for all terminal functionality BREAKING CHANGE: Terminal output now uses xterm.js rendering instead of HTML elements, affecting any CSS or DOM-based terminal interactions.
Remove verbose debug logging from production components to improve performance and reduce log noise in App.tsx, TerminalRenderer.tsx, and PTY manager. Fix WebSocket message counter to properly reset to zero when switching between sessions, ensuring accurate message tracking. Update E2E tests to work correctly with xterm.js terminal rendering, including proper session creation, selection, and input handling. Remove duplicate debug-info UI element that was causing layout issues. All changes maintain existing functionality while improving code quality and user experience.
- Split PTYManager into focused modules: SessionLifecycleManager, OutputManager, NotificationManager - Extract custom hooks from App component: useWebSocket, useSessionManager - Modularize web server by extracting route handlers into dedicated files - Add named constants for magic numbers and hard-coded strings These changes improve separation of concerns, reduce complexity, and enhance testability while preserving all existing functionality. All unit and e2e tests pass.
- Remove temporary console.log statements from test and e2e files to reduce log noise during development and testing - Remove removable log.debug statements from source code handlers, server, performance tracking, and main application - Preserve error-handling debug logs that serve production monitoring purposes - Update tests to remove expectations for removed log outputs and clean up unused variables - Delete integration test that validated specific log formats now removed
- Extract PTYSessionInfo creation to reusable toInfo method - Add formatLine utility for consistent line formatting in pty_read - Unify session cleanup logic in SessionLifecycle methods - Break down long startWebServer function into handleRequest - Extract ID_BYTES constant for session ID generation
Remove log.info calls from server, handlers, and test files to reduce log verbosity and clean up code. Remove associated imports and declarations. Replace empty logging callbacks with no-ops. Keep error logging intact. Also fix a test by adding session clear to ensure clean state.
- Extract shared error handling helper for session not found errors - Create reusable formatters for session info and output lines - Break down long functions in SessionLifecycle.spawn and pty_read.execute - Consolidate permission handling logic to reduce code duplication - Fix unused variable warnings in test files These changes improve code organization, reduce duplication, and enhance readability without altering functionality. All tests pass.
…ement - Extract TerminalRenderer into useTerminalSetup and useTerminalInput hooks - Add formatPtyOutput function for cleaner PTY output formatting - Improve type safety with non-null assertions and better process handling - Reorganize constants imports to eliminate duplication - Extract WebSocket message handlers into separate functions - Fix install script to ensure plugin directory exists BREAKING CHANGE: PTYSession.process can now be null during initialization
- Add test hook in TerminalRenderer to expose terminal instance for e2e testing - Modify static handler to serve built HTML in test mode - Create comprehensive e2e test demonstrating direct xterm buffer extraction - Test verifies content can be extracted from running terminal sessions This enables robust testing of terminal output and content extraction directly from xterm.js, supporting advanced e2e test scenarios.
- Install @xterm/addon-serialize package for advanced terminal serialization - Load SerializeAddon in TerminalRenderer for comprehensive content extraction - Add second e2e test demonstrating SerializeAddon usage - Test verifies clean text extraction with excludeModes/excludeAltBuffer options - Compare SerializeAddon (preserves ANSI codes) vs manual buffer extraction Both extraction methods now available for different testing needs: - Manual extraction: clean text, programmatic access - SerializeAddon: formatted output with ANSI escape sequences
Include an explicit 'bun run build' step in the Nix-based CI job to validate successful builds alongside dependency, quality, and test checks. Each step runs in its own Nix devShell for reliability and isolation.
Update the "build" script to exclude type checking. This speeds up builds for development and CI environments. Explicit type validation is assumed to occur in a separate step or script.
refactor prompt, echo, and fast-typing E2E tests to use xterm.js SerializeAddon buffer as the canonical assertion source. eliminate brittle DOM scraping and prompt-line matching in favor of robust, buffer-based validation. update character and event count assertions to tolerate batching and echo differences. all changes are limited to E2E tests and improve reliability, cross-browser and CI pass rate, and future maintainability for PTY/terminal interaction tests.
add strict policy for PTY/xterm E2E tests: require SerializeAddon helper for all test oracles, prohibit DOM scraping or prompt regexes for assertions. clarify with examples what is and isn't allowed, enforcement expectations, and rationale for robust, cross-platform testing. this enables reliable CI, readable changelogs, and guides future contributions. Refs: #ci, #testing, #contributors
remove unused imports, variables, and debug utility code from e2e/extraction-methods-echo-prompt-match.pw.ts, e2e/local-vs-remote-echo-fast-typing.pw.ts, e2e/newline-verification.pw.ts, and e2e/visual-verification-dom-vs-serialize-vs-plain.pw.ts - resolves TS6133 unused variable/function errors that blocked typechecking - ensures only canonical assertion methods are possible in E2E tests - aligns with newly documented terminal E2E policy no logic or test assertions changed; only unreachable code and debug helpers removed
replace separate test/build/quality steps with a matrix job that runs these checks in parallel, simplifying workflow and improving ci performance. removes duplicated code and enables fail-fast control.
The 'local-vs-remote-echo-fast-typing' Playwright E2E test now explicitly creates the required 'Local vs remote echo test' PTY session at the start of the test, using the api fixture. This resolves a test failure where the test would time out waiting for a missing session item, and brings the setup inline with other PTY E2E scenarios. No application logic is changed; this improves test reliability only.
- refactor GitHub Actions CI workflow to use more concise matrix entries and consolidate multiple job steps for quality checks - replace build step with 'bun run build:prod' for all jobs; test, typecheck, lint, and format:check now run via matrix entry and are simpler to maintain - remove obsolete 'build:all:dev' and 'build:all:prod' scripts from package.json; note: 'prepack' still references 'build:all:prod', which may require follow-up adjustment for consistency improves maintainability and clarity of CI and build configuration
update prepack step to use 'bun run build:prod' instead of the removed 'build:all:prod' script. this ensures that all required web assets are correctly built and included in the npm package. previously, packing was broken and integration/structure tests failed due to missing files.
add magic nix cache step to github actions workflow after nix install, enabling automatic caching of nix flake builds, dependencies, and downloads. this speeds up repeated ci runs by reducing redundant building and fetching.
include run test:e2e in main ci test matrix and install playwright browsers for e2e coverage in bun workflows. ensures e2e tests run automatically in ci with all required browser dependencies.
adds a newline at the end of .github/workflows/ci.yml to satisfy formatting best practices and avoid formatting warnings in GitHub or YAML linters.
the 'args' property is now required (must provide array) for ptySpawn tool definition. previously, it was optional. this enforces stricter input validation, but breaks usages where 'args' is omitted. BREAKING CHANGE: 'args' must now be included (as an array) when invoking ptySpawn; omitting it will result in validation errors.
- Move E2E tests from e2e/ to test/e2e/ for better organization - Update Playwright config paths for new test directory structure - Add E2ETestWebSocketClient for event-driven buffer testing - Enhance buffer extension test with WebSocket event monitoring - Improve test reliability by using event-driven assertions over timing-based - Update import paths and server startup commands for new structure
- Document WebSocket-based approach for flaky terminal tests - Add code examples showing event-driven buffer verification - Explain race condition elimination through event waiting - Include usage of E2ETestWebSocketClient and ManagedTestClient - Update browser debugging guidance Fixes flaky test by replacing HTTP polling with WebSocket event-driven verification
Remove E2ETestWebSocketClient wrapper class and consolidate all WebSocket testing functionality into ManagedTestClient in test/utils.ts. This simplifies the test infrastructure and eliminates code duplication. Key changes: - Delete e2e/helpers/websocketHelper.ts (114 lines) - Add verifyCharacterInEvents() method to ManagedTestClient - Update buffer-extension.pw.ts to use direct ManagedTestClient methods - Update fixtures.ts to use ManagedTestClient with 'using' pattern - Fix race condition in Event-Driven E2E Testing pattern documentation - Add opencode.json configuration file BREAKING CHANGE: E2ETestWebSocketClient class removed. Tests using it must migrate to ManagedTestClient directly.
Split monolithic 510-line AGENTS.md into 11 focused documents organized under .opencode/agents/docs/ for better maintainability. Changes: - Create docs subdirectory with quickstart, architecture, commands, code-style, testing, security, dependencies, release, contributing, and troubleshooting guides - Add index.md as navigation hub - Update opencode.json with new file references - Remove .opencode/ from .gitignore to track documentation - Simplify AGENTS.md to point to opencode.json This improves discoverability and reduces merge conflicts when updating individual documentation sections.
…larity - standardize ManagedTestClient initialization with getWsUrl in integration, pty, and websocket tests for clarity and correctness - refactor Playwright fixtures to use clearer parameter names and add explanatory comments for ignored errors - improve ANSI escape stripping functions for better consistency and cross-env compatibility - fix eslint/ts-ignore usage, whitespace, and multiline signatures in various helper files - ensure error handling in test helpers is robust and self-explanatory these changes enhance test suite maintainability and robustness but do not affect production code or APIs
increase timeout for when checking '● Connected' in the App component E2E test, to prevent flakiness when connection is slow
Fix inaccurate test commands in docs and expand AGENTS.md with comprehensive guide for agentic coding assistants. - Correct unit test command from `bun run test` to `bun test` - Fix unit test filtering flag from `--match` to `--test-name-pattern` - Add E2E environment variable details (PW_DISABLE_TS_ESM_1, NODE_ENV=test) - Document --repeat-each and --project options for E2E tests - Remove non-existent scripts (build:plugin, install:plugin:dev, test, test:watch) - Expand AGENTS.md from 6-line redirect to 139-line comprehensive guide - Add essential commands, critical warnings, architecture highlights - Add session lifecycle diagram, code conventions summary - Document bun-pty version check and special considerations These changes ensure agents have accurate, up-to-date documentation for working with repository, particularly around testing workflows.
replace empty destructured object {} with _ for unused parameter in
test server fixture, improving code readability and following common
conventions.
Remove unused React Hook dependencies from useSessionManager's
handleKillSession callback to fix ESLint exhaustive-deps warning.
Fix Playwright fixture empty object pattern ESLint error by using {}
with eslint-disable comment, as Playwright's base.extend() API requires
object destructuring even when unused.
Add eslint-disable comments for intentionally unused infer _ variables in ExtractParams type definition. The _ pattern is used to discard matched prefixes while extracting parameter names from route patterns.
Replace any type casting with proper type annotation for Chrome-specific performance.memory API. Add null check for safety. Remove unused variables and empty callback bodies from PerformanceObserver callbacks.
Replace unused catch error parameters with empty catch clauses. These variables were never used, and empty catch blocks are preferred for ignored errors per TypeScript/ESLint conventions.
Fix ESLint no-explicit-any warning in CustomError.toJSON method. Use proper type annotation instead of any cast for better type safety.
Fix ESLint no-explicit-any warning by using proper string type parameter for Bun.Server, which publishes string messages.
Use Bun.Server<undefined> instead of Bun.Server<string>. The generic type represents WebSocket data, and since no custom data is attached during upgrade, undefined is the correct type.
Define HealthResponse interface to properly type health response object, including optional responseTime field. Eliminates no-explicit-any warning by avoiding cast.
Use unknown type for more type safety. JSON.stringify accepts any type, and unknown provides better type checking than any.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses CI pipeline issues and introduces a comprehensive web UI for PTY session management.
Key Changes
Impact
Preview of this branch is available at: https://www.npmjs.com/package/opencode-pty-test